import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import show from '@dfeidao/atom-web/ui/show';

import nodejs from '@dfeidao/atom-web/msg/nodejs';

import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';

import set from '@dfeidao/atom-web/local/set';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';

export default async function a001(fd: IFeidaoAiBrowserComponent,arr: string) {
	// todo
	show(fd.data.node);
	const xuanze=fd.data.node.querySelector<HTMLDivElement>('[data-id="xuanze"]');
	set_node_cls(xuanze,'display-n',false);
	const res = await nodejs<{dt: Array<{question_bank_type: string,right_answer: string}>}>('question-bank/zj-000007/s001',{
		filter:{
			question_no:arr
		}
	});
	set (fd,'arr',arr);

	let a="";
	for (let c=0;c < res.dt.length;c++) {
		a += res.dt[c].right_answer;
	 }
	 render(fd,res.dt,p001,'p001','inner');

	const xuanxiangA=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangA"]');
	const xuanxiangB=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangB"]');
	const xuanxiangC=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangC"]');
	const xuanxiangD=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangD"]');
	if (a === "A") {
		xuanxiangA.checked = true;
	} else if (a === "B") {
		xuanxiangB.checked = true;

	} else if (a === "C") {
		xuanxiangC.checked = true;

	} else if (a === "D") {
		xuanxiangD.checked = true;
	}
}
